package com.example.myapplication;

import androidx.annotation.RequiresApi;
import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.os.SystemClock;
import android.view.View;
import android.widget.Chronometer;

public class AdActivity extends AppCompatActivity {

    Chronometer chronometer;

    @RequiresApi(api = Build.VERSION_CODES.N)
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_ad);

        chronometer=findViewById(R.id.chronometer);
        chronometer.setCountDown(true);
        chronometer.setBase(SystemClock.elapsedRealtime()+5000);
        chronometer.start();
        chronometer.setOnChronometerTickListener(new Chronometer.OnChronometerTickListener() {
            @Override
            public void onChronometerTick(Chronometer chronometer) {
                if (chronometer.getText().equals("00:00")){
                    chronometer.stop();
                    startActivity(new Intent(getApplicationContext(),LoginActivity.class));
                }
            }
        });
    }

    public void btnStart(View view) {
        startActivity(new Intent(this,ListActivity.class));
    }
}
